<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<%
    String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>${tabTitle}</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <form id="ins_cfg_info_edit_form">
                <div class="fieldset1 tabel_col clearFix">
                    <div class="fieldBox col_33">
                        <div class="label">机构名称</div>
                        <div class="field">
                            <span>${fundRasInsNm}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">客户名称</div>
                        <div class="field">
                            <span>${cstNm}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">学历</div>
                        <div class="field">
                            <select name="highDgCd" id="highDgCd" value="${highDgCd}" validate="{required:true}">
                                <c:if test="${highDgCd == null || highDgCd == ''}">
                                    <option value=" " selected="selected">--请选择--</option>
                                </c:if>
                                <c:if test="${highDgCd != null && highDgCd != ''}">
                                    <option value=" ">--请选择--</option>
                                </c:if>
                                <c:forEach items="${highDgCdList}" var="item">
                                    <c:if test="${item.key == highDgCd}">
                                        <option value="${item.key}" selected="selected">${item.value}</option>
                                    </c:if>
                                    <c:if test="${item.key != highDgCd}">
                                        <option value="${item.key}">${item.value}</option>
                                    </c:if>
                                </c:forEach>
                            </select>
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">月收入(元)</div>
                        <div class="field">
                            <input name="monthInc" id="monthInc" type="text" class="ui-textbox" value="${monthInc}" validate="{number:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                </div>

                <div class="label col_100">三类户开通</div>
                <div class="fieldset1 tabel_col clearFix">
                    <div class="fieldBox col_33">
                        <div class="label">开户银行</div>
                        <div class="field">
                            <span>${bkNm}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">银行卡号</div>
                        <div class="field">
                            <span>${accNo}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">银行预留手机号</div>
                        <div class="field">
                            <span>${mp}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">开户状态</div>
                        <div class="field">
                            <span>${accResMsg}</span>
                        </div>
                    </div>
                </div>

                <div class="label">还款卡签约信息</div>
                <div class="fieldset1 tabel_col clearFix">
                    <div class="fieldBox col_33">
                        <div class="label">开户银行</div>
                        <div class="field">
                            <span>${repayBkNm}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">银行卡号</div>
                        <div class="field">
                            <span>${repayAccNo}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">银行预留手机号</div>
                        <div class="field">
                            <span>${repayMp}</span>
                        </div>
                    </div>
                </div>

                    <!-- hide data -->
                    <div class="fieldBox col_100" style="display: none;">
                        <div class="field">
                            <input name="insCode" id="insCode" type="text" class="ui-textbox" value="${insCode}">
                            <input name="prjId" id="prjId" type="text" class="ui-textbox" value="${prjId}">
                            <input name="cstId" id="cstId" type="text" class="ui-textbox" value="${cstId}">
                            <input name="certNo" id="certNo" type="text" class="ui-textbox" value="${certNo}">
                            <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="${cstNm}">
                            <input name="cstAccInfoId" id="cstAccInfoId" type="text" class="ui-textbox" value="${cstAccInfoId}">
                            <input name="fundRasInsId" id=fundRasInsId type="text" class="ui-textbox" value="${fundRasInsId}">
                        </div>
                    </div>
                <div id="saveInsCfgDiv" class="btnsBox">
                    <span id="saveInsCfg" class="sq-button sq-button-round" onclick="return saveInfo();">保存</span>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">

    var detailFlag = '${detailFlag}';
    var fromCAFlag = '${fromCAFlag}';
    var fromCMFlag = '${fromCMFlag}';
    var creditPass = '${creditPass}';

    $(function () {
        initData();
    });

    function initData() {
        $("#ins_cfg_info_edit_form").ligerForm({
            validate: true
        });

        disabledInput();
        enableFields();
    }

    function enableFields() {
        if (null != fromCAFlag && "true" == fromCAFlag) {
            $("#saveInsCfgDiv").show();
        }
        if (null != fromCMFlag && "true" == fromCMFlag) {
            $("#saveInsCfgDiv").show();
        }
    }

    function disabledInput() {
        if (detailFlag == "true" || creditPass == "1") {
            liger.get("highDgCd").setDisabled();
            liger.get("monthInc").setDisabled();
        }
        if (detailFlag == "true") {
            $("#saveInsCfgDiv").hide();
        }
    }

    // 保存项目客户信息，后面弹出准入验证的资料确认页
    function saveInfo() {
        var ligerForm = liger.get("ins_cfg_info_edit_form");
        if (!ligerForm.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            //验证不通过，不执行以下代码
            return false;
        }
        var data = ligerForm.getData();
        if(!$("#highDgCd").val()){
            top.$.ligerDialog.SQalert({content: "请选择学历！", SQ_type: "error"});
            return false;
        }
        if(!$("#monthInc").val()){
            top.$.ligerDialog.SQalert({content: "请填写月收入！", SQ_type: "error"});
            return false;
        }
        data["certNo"] = $("#certNo").val();
        data["cstAccInfoId"] = $("#cstAccInfoId").val();
        data["insCode"] = $("#insCode").val();
        data["prjId"] = $("#prjId").val();
        data["cstId"] = $("#cstId").val();
        data["cstNm"] = $("#cstNm").val();
        data["fundRasInsId"] = $("#fundRasInsId").val();
        data["highDgCd"] = $("#highDgCd").val();
        data["monthInc"] = $("#monthInc").val();

        var url = '<%=path%>/institution/spdbankde/saveForSpdbankde.do';
        var wait_dialog;
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: url,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    //新增时赋值
                    if ($("#cstAccInfoId").val() == "" && msg.data != null) {
                        $("#cstAccInfoId").val(msg.data);
                    }
                    UIUtils.alertSuccessHold1(msg.info);
                } else {
                    UIUtils.alertErrorHold1(msg.info);
                }
            }
        });
    }
</script>
</body>
</html>